#define DEBUG
#include <cstdio>

using namespace std;

const int maxn=400, maxm=4000, inf=0x7ffffff;

int min(int a, int b) {
  return a<b ? a : b;
}

class Graph {
public:
  int n, m, a[maxn+1], ind[maxn+1], to[2*maxm+1], link[2*maxm+1], val[2*maxm+1];
  long long dis[maxn+1], f[maxn+1];
  bool only[maxn+1];

  void init(int n) {
    this->n = n;
    m=0;
    for (int i=1; i<=n; i++) {
      ind[i]=0;
    }
  }

  void addSide(int u, int v, int c) {
    m++;
    to[m] = v;
    val[m] = c;
    link[m] = ind[u];
    ind[u] = m;
  }

  void dij() {
    static bool book[maxn+1];
    for (int i=0; i<=n; i++) {
      dis[i]=inf, only[i]=true;
    }
    dis[1]=0, f[1]=inf, book[1]=true;
    for (int i=1; i<=n; i++) {
      int o=0;
      for (int j=1; j<=n; j++) {
	if (book[j] && dis[j]<dis[o]) {
	  o = j;
	}
      }
      book[o]=false;
      for (int j=ind[o]; j; j=link[j]) {
	if (dis[to[j]]>dis[o]+val[j]) {
	  dis[to[j]]=dis[o]+val[j];
	  f[to[j]]=0, only[to[j]]=true;
	  book[to[j]]=true;
	}
	if (dis[to[j]]==dis[o]+val[j]) {
	  f[to[j]]+=min(f[o], min(a[o], a[to[j]]));
	  only[to[j]] = only[to[j]] && (a[o]!=a[to[j]]) && f[o]!=min(a[o], a[to[j]]);
	}
      }
    }
  }
};

int main() {
#ifdef DEBUG
  freopen("1.in", "r", stdin);
  freopen("1.out", "w", stdout);
#endif

  static Graph g;
  int t;
  scanf("%d", &t);
  for (int ti=1; ti<=t; ti++) {
    int n, m;
    scanf("%d %d", &n, &m);
    g.init(n);
    for (int i=1; i<n; i++) {
      scanf("%d", &g.a[i]);
    }
    g.a[n]=inf;
    for (int i=1; i<=m; i++) {
      int u, v, c;
      scanf("%d %d %d", &u, &v, &c);
      g.addSide(u, v, c);
      g.addSide(v, u, c);
    }
    g.dij();
    printf("%s %lld\n", g.only[n] ? "Yes" : "No", g.f[n]);
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
